/**
 * 
 */
package edu.bbk.muc.lifetracker.logging;

import edu.bbk.muc.lifetracker.DbAdapter;

/**
 * Contains common characteristics for different kinds of logging to KML files.
 * 
 * @author irenatyler and romankirillov
 * 
 */
public abstract class KMLLogger extends Logger {
  protected String xmlBody;
  protected String nameTag;
  protected String descTag;
  protected String name;
  protected String description;
  protected String xml; // the whole xml document with content
  private String folder;

  /**
   * Initialises this {@link KMLLogger}'s and parent class fields.
   * @param dbAdapter DB adapter which is used to read stored data.
   */
  public KMLLogger(DbAdapter dbAdapter) {
    super(dbAdapter);
    fileExtension = ".xml";
  }

  /**
   * Gets the whole xml document.
   * 
   * @return xml document
   */
  public String getXml() {
    folder = "Life Tracker placemarks";
    return String
        .format(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?><kml xmlns=\"http://www.opengis.net/kml/2.2\"><Folder><name>%1$s</name>%2$s</Folder></kml>",
            folder, getXmlBody());
  }

  @Override
  public
  String getFileContent() {
    return getXml();
  }

  /**
   * Gets xml text to use in a log, applicable for specific kml logger.
   * 
   * @return xml text
   */
  abstract String getXmlBody();

}
